#ifndef POSIX_MESSAGE_QUEUE_H
#define POSIX_MESSAGE_QUEUE_H

#include <mqueue.h>
#include <string>
#include <functional>
#include <thread>
#include <pthread.h>

class POSIX_MessageQueue
{
  public:
    POSIX_MessageQueue(const std::string & name);
    virtual ~POSIX_MessageQueue();
    void BootActiveReceive(std::function<void(std::string)> func);
    std::string ReceiveData();
    void SendData(const std::string & val);
  private:
    pthread_t threadID;
    mqd_t id;
    long ReceiveMessageSize;
    char* ReceiveMessageBuffer;
    std::function<void(std::string)> ReceiveDataCallback;
    std::jthread receiveThread;
    void ReceiveFunc(std::stop_token token);
};

#endif
